package com.itheima.health.jobs;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.health.service.OrderSettingService;
import lombok.extern.slf4j.Slf4j;

import java.util.Calendar;
import java.util.Date;

/**
 * @author xzt
 * @description 定时任务：清理历史数据
 * @date 2020/1/1
 **/
@Slf4j
public class CleanDataJob {


    @Reference
    private OrderSettingService orderSettingService;

    /**
     * 定义清理历史数据的任务
     */
    public void cleanDataJob(){
        log.info("[清理数据]开始....");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_YEAR,-1);
        //calendar.set(Calendar.DAY_OF_MONTH,-1);
        Date time = calendar.getTime();
        log.info("[time]time:{}",time);
        orderSettingService.deleteByOrderDate(time);
        log.info("[清理数据]结束....");
    }
}
